require 'rake'
require 'sqlite3'

task :default => [:test]

desc 'Runs all test cases'
task :test do
	#TODO
end

JATIT_DIR = File.expand_path('~/.jatit')
JATIT_DATABASE_FILE_NAME = 'jatit.db'
JATIT_DATABASE_FILE_PATH = File.join(JATIT_DIR, JATIT_DATABASE_FILE_NAME)

desc 'Creates user jatit directory'
directory JATIT_DIR 

desc 'Creates the sqlite3 empty database in the user jatit dir.'
task :create_database => [JATIT_DIR] do
	db = SQLite3::Database.new( JATIT_DATABASE_FILE_PATH )
	File.open('create.sql') {|file| db.execute_batch(file.read)}
end

desc 'Populates the jatit database with test data'
task :load_database_data => [:create_database] do
	db = SQLite3::Database.new( JATIT_DATABASE_FILE_PATH )
	File.open('test_data.sql') {|file| db.execute_batch(file.read)}
end
